package cn.cyh.queue_service.controller;

import cn.cyh.queue_service.common.Result;
import cn.cyh.queue_service.model.dto.PageRequest;
import cn.cyh.queue_service.model.dto.PageResult;
import cn.cyh.queue_service.model.entity.Queue;
import cn.cyh.queue_service.model.entity.Window;
import cn.cyh.queue_service.model.vo.NoticeVO;
import cn.cyh.queue_service.model.vo.QueueVO;
import cn.cyh.queue_service.model.vo.WindowVO;
import cn.cyh.queue_service.service.NoticeService;
import cn.cyh.queue_service.service.QueueService;
import cn.cyh.queue_service.service.WindowService;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 大屏
 *
 * @author xujunwen
 * @since 2025-04-11 08:21
 **/
@RestController
@RequestMapping("/callScreen")
public class CallScreenController {

    @Resource
    private QueueService queueService;

    @Resource
    private WindowService windowService;

    @Resource
    private NoticeService noticeService;

    @RequestMapping("geCallScreenData")
    @Operation(summary = "大屏", description = "获取大屏数据")
    public Result<JSONObject> geCallScreenData() {
        JSONObject res = new JSONObject();
        // 当前叫号
        Queue currentCall = queueService.getCurrentQueue();
        res.set("currentCall", currentCall);
        // 窗口状态
        PageRequest page = new PageRequest(1, 100);
        PageResult<WindowVO> windowList = windowService.getWindowList(page);
        res.set("queueStatus", windowList);
        // 当前排队
        List<QueueVO> waitingQueues = queueService.getWaitingQueues();
        res.set("queueList", waitingQueues);
        // 综合统计
        List<Queue> todayQueue = queueService.geTodayQueue();
        res.set("allQueue", todayQueue);
        // 通知公告
        List<NoticeVO> noticeVOS = noticeService.getActiveNotices();
        res.set("noticeList", noticeVOS);
        return Result.success(res);
    }


}
